﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using DevExpress.Xpf.Docking;
using Modularity;
using OpenLS.Spreadsheet;
using OpenLS.Spreadsheet.Formats;
using QuantumWorkspace.SessionManager;

namespace GenericGridControl
{
    /// <summary>
    /// Interaction logic for MarketDataTableControl.xaml
    /// </summary>
    public partial class MarketDataTableControl : LayoutPanel
    {
        public MarketDataTableControl()
        {
            InitializeComponent();
            _bigDataTableViewModel = new ModuleViewModel<EODDataModule>();
            _bigDataTableViewModel.CurrentDataModule.CurrentGridControl = this.dynamicTableGrid;
            this.DataContext = _bigDataTableViewModel;
        }

        private string _tableName;
        private JsonDataTableFormat _JsonTableStructure;

        private ModuleViewModel<EODDataModule> _bigDataTableViewModel;


        public Workbook CurrentWorkbook
        {
            set { this._bigDataTableViewModel.CurrentDataModule.CurrentWorkbook = value; }
        }

        public void DefineTableJsonFormat(JsonDataTableFormat structure)
        {
            _JsonTableStructure = structure;
            _bigDataTableViewModel.CurrentDataModule.DefineTableJsonFormat(structure);
            _bigDataTableViewModel.TableName = structure.TableName;
            _bigDataTableViewModel.TableComment = structure.Comment;
        }

   
        private void CopyButton_Click(object sender, RoutedEventArgs e)
        {
            _bigDataTableViewModel.CurrentDataModule.CopyToSpreadsheet();
        }
    }
}
